from toee import *

def OnBeginSpellCast( spell ):
	print "Minor Globe of Invulnerability OnBeginSpellCast"
	print "spell.target_list=", spell.target_list
	print "spell.caster=", spell.caster, " caster.level= ", spell.caster_level
	game.particles( "sp-abjuration-conjure", spell.caster )

def	OnSpellEffect( spell ):
	print "Minor Globe of Invulnerability OnSpellEffect"

	spell.duration = 1 * spell.caster_level
	target_item = spell.target_list[0]

	npc = spell.caster			##  added so NPC's can use wand/potion/scroll
	if npc.name == 20123:
		spell.duration = 10
		spell.caster_level = 10
	if npc.type != obj_t_pc and npc.leader_get() == OBJ_HANDLE_NULL and spell.duration <= 0:
		spell.duration = 10
		spell.caster_level = 10

	# put sp-Minor Globe condition on target
	spell_obj_partsys_id = game.particles( 'sp-Minor Globe of Invulnerability', target_item.obj )
#	target_item.partsys_id = game.particles( 'sp-Minor Globe of Invulnerability', target_item.obj )
	target_item.obj.condition_add_with_args( 'sp-Minor Globe of Invulnerability', spell.id, spell.duration, 0, spell_obj_partsys_id )
	#target_item.obj.condition_add_arg_x( 3, spell_obj_partsys_id )
	#objectevent_id = target_item.obj.condition_get_arg_x( 2 )

def OnBeginRound( spell ):
	print "Minor Globe of Invulnerability OnBeginRound"

def OnEndSpellCast( spell ):
	print "Minor Globe of Invulnerability OnEndSpellCast"

def OnAreaOfEffectHit( spell ):
	print "Minor Globe of Invulnerability OnAreaOfEffectHit"

def OnSpellStruck( spell ):
	print "Minor Globe of Invulnerability OnSpellStruck"